﻿<!doctype html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>登录</title>
<link rel="stylesheet" type="text/css" href="../js/css/styles.css">
<link rel="stylesheet" type="text/css" href="../js/layui/css/layui.css">
</head>
<body>
<div class="htmleaf-container">
	<div class="wrapper">
		<div class="container">
			<h1>登陆</h1>
			
			<form class="form" action="/" method="post">
				<input type="text" placeholder="用户名" name="account" id="account" value="admin">
				<input type="password" placeholder="密码" name="password" id="password" value="admin">
				<button type="button" id="login-button">登陆</button>
			</form>
		</div>
		
		<ul class="bg-bubbles">
			<li></li>
			<li></li>
			<li></li>
			<li></li>
			<li></li>
			<li></li>
			<li></li>
			<li></li>
			<li></li>
			<li></li>
		</ul>
	</div>
</div>
<div style="text-align:center;margin:50px 0; font:normal 14px/24px 'MicroSoft YaHei';color:#000000">
<h1>人物关系</h1>
</div>
</body>
<script src="../js/jquery-3.3.1.js" type="text/javascript"></script>
<script src="../js/layui/layui.js" type="text/javascript"></script>
<script>
$(function(){
	var layer ;
	var host = location.host;
	var curWwwPath=window.document.location.href;
	var pathName=window.document.location.pathname;
	var pos=curWwwPath.indexOf(pathName);
	var localhostPaht=curWwwPath.substring(0,pos);
	layui.use('layer', function(){
			layer = layui.layer;
		 
		}); 
	$('#login-button').click(function (event) {
		event.preventDefault();
		$('form').fadeOut(500);
		$('.wrapper').addClass('form-success');
		var account = $("#account").val();
		var password = $("#password").val();
		console.log(JSON.stringify({"account":account,"password":password}))
		$.ajax({
				url: "login",
	            //dataType: "json", //传参的数据类型
	            type: "POST",//方式，get 或post
	            //contentType:"application/json;charset=utf-8",
	            data:{"account":account,"password":password},
				success:function(data){
					debugger;
					/* layer.msg(host); */
					if(data.code==1){
						
						window.location.href=localhostPaht+"/index/index.html"
					}else{
						layer.msg("登录失败！");
					}
					
				},error:function(data){
					
				}
		})
	});
});
</script>
</html>